package com.application.meizhi.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import com.application.meizhi.base.BasePresenter;
import com.orhanobut.logger.Logger;


import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by gskl on 16/10/9.
 */

public abstract class BaseActivity<T extends BasePresenter> extends AppCompatActivity {
    protected String TAG = this.getClass().getSimpleName();

    protected T presenter;

    protected Unbinder unbinder;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutId());
        unbinder = ButterKnife.bind(this);
        initPresenter();
    }

    protected abstract void initPresenter();

    protected abstract int getLayoutId();

    @Override
    protected void onStart() {
        super.onStart();
        Logger.i(TAG,"onStart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        Logger.i(TAG,"onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        Logger.i(TAG,"onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        Logger.i(TAG,"onStop");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        Logger.i(TAG,"onRestart");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
        Logger.i(TAG,"onDestroy");
    }
}
